xfs: avoid mount-time deadlock in CoW extent recovery
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 16 May 2017 02:16:15 +0000 (19:16 -0700)
committerRaspbian kernel package updater <root@raspbian.org>
Sun, 23 Jul 2017 02:53:48 +0000 (02:53 +0000)
commit950e98d71393b6ea5960beb9d3ef5f544462398a
tree60f34a6aaf88b44d4063985507380b3d9cc3891e
parentbce2b33b1912f55ad56083ab1848d9f3550a7b31
xfs: avoid mount-time deadlock in CoW extent recovery

commit 3ecb3ac7b950ff8f6c6a61e8b7b0d6e3546429a0 upstream.

If a malicious user corrupts the refcount btree to cause a cycle between
different levels of the tree, the next mount attempt will deadlock in
the CoW recovery routine while grabbing buffer locks.  We can use the
ability to re-grab a buffer that was previous locked to a transaction to
avoid deadlocks, so do that here.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/xfs/libxfs/xfs_refcount.c